# Maintainer: @naveen521kk on Github, Naveen M K <naveen@syrusdark.website>

_realname=delta
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.7.1
pkgrel=1
pkgdesc='A syntax-highlighting pager for git and diff output (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://github.com/dandavison/delta"
license=('MIT')
depends=('git')
makedepends=("${MINGW_PACKAGE_PREFIX}-rust")
source=("https://github.com/dandavison/delta/archive/refs/tags/$pkgver.tar.gz")
sha256sums=('f432335361088c37f8aa4bb747ba12e1f8eddbbc3ed5c51fdd52d9b96eb22227')

prepare() {
  cp -r ${_realname}-${pkgver} build-${CARCH}
  ${MINGW_PREFIX}/bin/cargo fetch \
    --locked \
	--manifest-path build-${CARCH}/Cargo.toml
}

build() {
  ${MINGW_PREFIX}/bin/cargo build \
	--release \
	--frozen \
	--manifest-path build-${CARCH}/Cargo.toml
}

check() {
  ${MINGW_PREFIX}/bin/cargo test \
	--release \
	--frozen \
	--manifest-path build-${CARCH}/Cargo.toml
}

package() {
  ${MINGW_PREFIX}/bin/cargo install \
	--frozen \
	--offline \
	--no-track \
	--path build-${CARCH} \
	--root ${pkgdir}${MINGW_PREFIX}

  install -Dm644 ${_realname}-${pkgver}/LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
  install -Dm644 ${_realname}-${pkgver}/etc/completion/completion.bash "${pkgdir}${MINGW_PREFIX}/share/bash-completion/completions/$_realname"
  install -Dm644 ${_realname}-${pkgver}/etc/completion/completion.zsh  "${pkgdir}${MINGW_PREFIX}/share/zsh/site-functions/_$_realname"
}
